import Axios from 'axios';

const serverBase = 'http://47.95.158.230:8010/'
export default {
    //查询教师基本信息 id是当前页面权限id
    async findteacherinfo(id) {
        var flag = false;
        //查询用户的所有信息
        const url = serverBase + "teacherinfo/getById?id=" + sessionStorage.getItem("userid");
        await Axios.get(url).then((response) => {
            //response.data.roleId角色id
            //id是当前页面权限
            flag= this.findmyRole(response.data.roleId, id)
        }).catch((error) => {
        })
        return flag
    },
    async findmyRole(roleid, id) {//roleid是角色    id:当前页面权限id
        var flag = false;
        //查询角色的所有权限
        const url = serverBase + "role/getById?id=" + roleid;
        await Axios.get(url).then((response) => {
            var perlist = response.data.perId.split(",");
            for (var i = 0; i < perlist.length; i++) {
                if (perlist[i] == id) {
                    flag = true;
                    break;
                }
                else {
                    flag = false;
                }

            }
        }).catch((error) => {
        })
        
        return flag;
    }
} 
